package br.com.informatos.sqlite;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class addNoteActivity extends Activity {

	private NotesDAO dao;


	@Override
	protected void onCreate(Bundle savedInstanceState) {		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.add_note);

		dao = new NotesDAO(this);
		dao.Open();

		Button saveButton = (Button) findViewById(R.id.save_note_button);
		final EditText noteText = (EditText) findViewById(R.id.note_text);



		saveButton.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				String note = noteText.getEditableText().toString();
				Toast.makeText(getBaseContext(),note, Toast.LENGTH_LONG).show();
				if(note.equals(null) || note.equals("")) {
					Toast.makeText(getBaseContext(),"INFORME UMA NOTIFICAÇAÔ", Toast.LENGTH_LONG).show();
					
				}else{
					dao.create(note);
					finish();

				}


			}
		});

	}

	protected void onResume() {
		dao.Open();
		super.onResume();
	}

	@Override
	protected void onPause() {
		dao.close();
		super.onPause();
	}


}
